package com.example.sourcesprng.jdk17._switch;

public class TestJDK17_Switch_Type {

    public static void main(String[] args) {
        String str = "好好好";
        print(str);
        double d = 23.23D;
        print(d);
    }

    private static void print(Object obj) {
        switch (obj) {
            case Integer i -> System.out.println(String.format("Integer %d", i));
            case Long i -> System.out.println(String.format("Long %d", i));
            case Double i -> System.out.println(String.format("Double %.2f", i));
            case String i -> System.out.println(String.format("String %s", i));
            default -> System.out.println("其他类型");
        }
    }
}
